<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>迭代器</title>
</head>
<body>
    
</body>
</html>
<script>
    //迭代器方法
    //通过迭代对象获取索引
    // const hd = ["houduren","hdcms"];
    // //迭代对象
    // const keys = hd.keys();
    // console.log(keys.next());//{value:0,done:false}
    // console.log(keys.next());//{value:1,done:false}
    // console.log(keys.next());//{value:undefined,done:true} 代表已经迭代完毕

    //获取数组中所有的键
    // "use strict";
    // const arr = ["a","b","c","后盾人"];
    // for(const key of arr.keys()){
    //     console.log(arr[key])
    // }
    
    //使用while遍历
    // let arr = ["hdcms","oudurenrn"];
    // while({value,done} = arr.keys()){
    //     console.log(value)
    // }


    //values
    //通过迭代对象获取对象的值
    // const hd = ["houdurnen","hdcms"];
    //值的迭代对象
    // const values = hd.values();
    // console.log(values.next());
    // console.log(values.next());
    // console.log(values.next());
    // const arr = ["a", "b", "c", "后盾人"];
    // //获取数组的所有值
    // for(const value of arr.values()){
    //     console.log(value)
    // }

    //entries  迭代对象
    //使用entries获取迭代对象，获取的是数组的键值对
    // const arr = ["a","b","c","厚度柔嫩"];
    // for(const [key,value] of arr.entries()){
    //     console.log(key,value);
    // }

    //for in  循环出来得到数组的键
    //for of 循环出来得到数组的值
    //for of arr.keys()   通过迭代器获取数组的键
    //for of arr.values()  通过迭代获取数组的值

    //解构获取内容
    // const hd = ["houdurnen","hdcms"];
    // const iderator = hd.entries();//Array Iterator
    // let {done,value:[k,v]} = iderator.next();
    // console.log(v)
    // console.log(v)
    // console.log(v)
    // console.log(v)
    // console.log(v)
    // console.log(v)


    
</script>